#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    qDebug() << "main:" << QThread::currentThreadId();
    thread = new QThread(this);
    myt = new Deal;
    myt->moveToThread(thread);
    connect(this,&MainWindow::lunch1,myt,&Deal::lunch1);
    connect(this,&MainWindow::lunch2,myt,&Deal::lunch2);
    connect(this,&MainWindow::lunch3,myt,&Deal::lunch3);
    connect(thread,&QThread::finished,myt,&Deal::deleteLater);

}

MainWindow::~MainWindow()
{
    thread->quit();
    thread->wait();

    delete ui;
}

void MainWindow::on_pushButton1_clicked()
{
    thread->start();
    emit lunch1();
}

void MainWindow::on_pushButton2_clicked()
{
    emit lunch2();
}

void MainWindow::on_pushButton3_clicked()
{
    emit lunch3();
}
void MainWindow::lunch1Slot(){

}

void MainWindow::lunch2Slot(){

}

void MainWindow::lunch3Slot(){

}
